class TimerManager{
    constructor(){
        this.timers=[];
    }
    setTimeout(cb,delay){
        let n=setTimeout(cb,delay);
        this.timers.push(n);
        return n;
    }
    clearTimeout(n){
        let index=this.timers.indexOf(n);
        if(index>=0){
            clearTimeout(this.timers[index]);
            this.timers.splice(index,1);
        }
    }
    clear(){
        for(let i=0;i<this.timers.length;i++){
            clearTimeout(this.timers[i]);
            this.timers=[];
        }
    }
}

module.exports=TimerManager;